package com.sumec.controller;

import com.sumec.service.IWorkSumService;
import com.sumec.util.CommonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WorkSumController extends BaseController {
    private final static Logger log = LoggerFactory.getLogger(WorkSumController.class);

    @Autowired
    private IWorkSumService workSumService;

    @RequestMapping(value = "/initUserWorkSummary", method = {RequestMethod.GET})
    @ResponseBody
    public CommonResult initUserWorkSummary() {
        try {
            workSumService.initUserWorkSummary();
            return success();
        } catch (Exception e) {
            log.error("initUserWorkSummary异常", e);
            return error(e.getMessage());
        }
    }

    @RequestMapping(value = "/rankWorkSummary", method = {RequestMethod.GET})
    @ResponseBody
    public CommonResult rankWorkSummary() {
        try {
            workSumService.rankWorkSummary();
            return success();
        } catch (Exception e) {
            log.error("rankWorkSummary异常", e);
            return error(e.getMessage());
        }
    }

}
